package com.xyazm.customer.api;

import com.xyazm.common.core.JsonResult;
import com.xyazm.common.utils.ParamCheckUtil;
import com.xyazm.customer.domain.param.ReceiveAfterSaleAuditParam;
import com.xyazm.customer.exception.CustomerBizException;
import com.xyazm.customer.service.ICustomerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 客服服务对外暴露api实现类
 * @author xuyou
 * @date 2022年07月20日 8:16
 */
@Slf4j
@DubboService(version = "1.0.0",interfaceClass = ICustomerApi.class)
public class CustomerApi implements ICustomerApi {

    @Autowired
    private ICustomerService customerService;


    @Override
    public JsonResult<Boolean> receiveAfterSaleAudit(ReceiveAfterSaleAuditParam param) {
        try {
            ParamCheckUtil.checkObjectNonNull(param);
            customerService.receiveAfterSaleAudit(param);
            return JsonResult.buildSuccess();
        } catch (CustomerBizException e) {
            log.error("biz error", e);
            return JsonResult.buildError(e.getErrorCode(), e.getErrorMsg());
        } catch(Exception e) {
            log.error("system error", e);
            return JsonResult.buildError(e.getMessage());
        }
    }
}
